<template>
    <div class="app">
        <div style="flex:1;width: 750px; background-color: #F7F7F7">
            <myNavbar title="收款方式" backTyep="1"></myNavbar>
            <list style="flex: 1; width: 710px; margin-left: 20px;margin-top:10px">
                <cell v-for="(item,index) in accountlist">
                    <div style="margin-top: 10px; margin-bottom: 10px; width: 710px; height: 100px; border-radius: 10px; background-color: #ffffff">
                        <div style="flex-direction: row; width: 870px" ref="itemDev" @swipe="handleSwipe($event,index)">
                            <div style="justify-content: center; width: 710px; height: 100px; background-color: #ffffff">
                                <div class="submit_payMethod_Content" @click="selectbank(item,index)">
                                    <div>
                                        <div class="submit_payMethod_Content_Column_wrap">
                                            <div class="submit_payMethod_Content_Column_image">
                                                <image v-if="item.bankInfoId == 30" style="width: 50px;height: 50px" src="https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/bankJH.png"></image>
                                                <image v-else-if="item.bankInfoId == 2" style="width: 50px;height: 50px" src="https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/Alipay.png"></image>
                                                <image v-else-if="item.bankInfoId == 1" style="width: 50px;height: 50px;" src="https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/weixin1.png"></image>
                                                <image v-else style="width: 50px;height: 50px" src="https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/bankAll.png"></image>
                                            </div>
                                            <div class="submit_payMethod_Content_Title_wrap">
                                                <text class="submit_payMethod_Content_Title"> {{item.bankName}} {{item.bankNum}}</text>
                                            </div>
                                        </div>
                                    </div>
                                    <image v-if="index == num" style="width: 50px;height: 50px" src="https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/Hook.png"></image>
                                </div>
                            </div>
                            <div style="background-color: #ff0000; width: 160px; height: 100px; justify-content: center; align-items: center" @click="removeItem(item,index)">
                                <text style="font-size: 30px; color:#ffffff">删除</text>
                            </div>
                        </div>
                    </div>
                </cell>
                <cell>
                  <div style="width:100px;height:100px"></div>
                </cell>
            </list>
        </div>
        <div class="realName_botton" @click="addNewCard">
            <text class="realName_botton_text">{{'添加新收款方式'}}</text>
        </div>
    </div>
</template>

<script>
import { list as accountlist , del} from "../../../api/account";
import myNavbar from "../../../components/myNavbar/myNavbar";
const animation = weex.requireModule("animation");
const eeui = app.requireModule("eeui");
export default {
    components: { myNavbar },
    data() {
        return {
            num: "1",
            accountlist: [],
            accountlistitem: {},
            isClose: "", //控制是关闭弹窗还是跳转订单确认页面
            flag: true,
            currentIndex: -1,
        };
    },
    mounted() {
        // this.getOrderCount()
        this.getBank();
    },
    pageResume: function (data) {
        this.getBank();
    },
    methods: {
        selectbank(item, index) {
            this.num = index;
            this.accountlistitem = item;
        },
        getBank() {
            accountlist()
                .then((res) => {
                    this.accountlist = res.data;
                })
                .catch((respond) => {});
        },
        addNewCard() {
            console.log("321321");
            eeui.openPage(
                {
                    url: "root://pages/member/transferSystem/distribution/addBank",
                    statusBarType: "immersion",
                    statusBarStyle: false,
                },
                (result) => {}
            );
        },

        submit() {
            this.hideFrame();
            this.$emit("selectedInfo", this.accountlistitem);
        },
        //显示底部弹窗
        showFrame(id, type) {
            this.flag = true;
        },

        //隐藏底部弹窗
        hideFrame() {
            this.wrapAnimate = "wrapAnimateOut";
            this.frameAnimate = "frameAnimateOut";
            setTimeout(() => {
                this.flag = false;
            }, 400);
        },

        handleSwipe(e, index) {
            if (e.direction == "left") {
                this.goLeft(index);
            } else if (e.direction == "right") {
                this.goRight(index);
            }
        },
        goLeft(index) {
            let itemEl = this.$refs.itemDev[index]; //第二左滑条目与前一次左滑条目相同时，不处理
            if (index == this.currentIndex) {
                return;
            } //当前有划出的条目的时候，左滑其他条目，当前的条目归位，
            if (this.currentIndex != -1) {
                this.goRight(this.currentIndex);
            } //左滑当前条目
            if (this.currentIndex != index) {
                animation.transition(
                    itemEl,
                    {
                        styles: {
                            transform: "translate(-160px, 0px)",
                            transformOrigin: "center center",
                        },
                        duration: 200, //ms
                        timingFunction: "linear",
                        delay: 0, //ms
                    },
                    function () {}
                );
                this.currentIndex = index;
            }
        }, //time是动画时间，给个默认值 200毫秒，不传就表明这个值为200毫秒
        goRight(index, time = 200) {
            let itemEl = this.$refs.itemDev[index];
            animation.transition(
                itemEl,
                {
                    styles: {
                        transform: "translate(0px, 0px)",
                        transformOrigin: "center center",
                    },
                    duration: time, //动画时间
                    timingFunction: "linear", //线性运动
                    delay: 0, //ms
                },
                function () {}
            );

            this.currentIndex = -1;
        }, //点击删除

        removeItem(item,index) {
            var _this = this
            console.log(item)
            del(item.id).then(res=>{
                _this.goRight(index, 0);
                _this.accountlist.splice(index, 1);
            })
        },
    },
};
</script>

<style lang="css" src="../../../style/wx.css" />
<style scoped>
.app,
body {
    background-color: rgba(248, 248, 248, 0.8);
}

.bottomFrame {
    border-style: solid;
    background-color: #a1a1a1;
    border-width: 1px;
    border-color: #000;
    z-index: 200;
    position: fixed;
}

.frame-wrapper {
    background-color: rgba(0, 0, 0, 0.5);
    position: fixed;
    z-index: 201;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* border-top-left-radius: 20px;
  border-top-right-radius: 20px; */
}

.frame {
    background-color: #fff;
    position: absolute;
    bottom: 0px;
    width: 750px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 201;
}

.content {
    padding: 30px 0 0 30px;
    position: relative;
    min-height: 800px;
}

.bottomFrame-icon-close {
    /*width: 70px;*/
    /*height: 70px;*/
    position: absolute;
    right: 30px;
    font-size: 38px;
}

.bottomFrame-top {
    display: flex;
    flex-direction: row;
    border-bottom-style: solid;
    border-bottom-width: 2px;
    border-bottom-color: rgba(211, 211, 211, 0.719);
}

/* 以下是弹窗的动画效果 */
.wrapAnimate {
    /* animation: wrapAnimate 0.5s ease-in-out forwards; */
    transition-timing-function: ease-in-out;
    transition-duration: 0.5s;
    transition-property: height;
}

@keyframes wrapAnimate {
    0% {
    }

    100% {
        background: rgba(0, 0, 0, 0.35);
    }
}

.wrapAnimateOut {
    animation: wrapAnimateOut 0.5s ease-in-out forwards;
}

@keyframes wrapAnimateOut {
    0% {
        background: rgba(0, 0, 0, 0.35);
    }

    100% {
        background: rgba(0, 0, 0, 0);
    }
}

.frameAnimate {
    /* animation: frameAnimate 0.5s ease forwards; */
    transition-timing-function: ease;
    transition-duration: 0.5s;
    transition-property: height, background-color;
}

@keyframes frameAnimate {
    0% {
    }

    100% {
        opacity: 1;
        top: 0px;
    }
}

.frameAnimateOut {
    /* animation: frameAnimateOut 0.5s ease forwards; */
    transition-timing-function: ease;
    transition-duration: 0.5s;
    transition-property: height, background-color;
}

@keyframes frameAnimateOut {
    0% {
        opacity: 1;
        top: 0px;
    }

    100% {
        opacity: 0;
        bottom: 0px;
    }
}
.content {
    padding-top: 30px;
    padding-left: 30px;
    padding-bottom: 30px;
    padding-right: 30px;
}

.bottomFrame-icon-close {
    font-size: 50px;
    color: black;
    position: absolute;
    /* right: 30px; */
    left: 30px;
    color: #a1a1a1;
}

.bottomFrame-top {
    display: flex;
    flex-direction: row;
}

.bottomFrame-top image {
    width: 200px;
    height: 200px;
    margin-right: 20px;
    border-radius: 6px;
}

.bottomFrame-attribute-tag image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-right: 20px;
}

.bottomFrame-attribute-tag text {
    font-size: 28px;
    letter-spacing: 2px;
}

/* 以下是弹窗的动画效果 */
.wrapAnimate {
    animation: wrapAnimate 0.5s ease-in-out forwards;
}

@keyframes wrapAnimate {
    0% {
    }

    100% {
        background: rgba(0, 0, 0, 0.35);
    }
}

.wrapAnimateOut {
    animation: wrapAnimateOut 0.5s ease-in-out forwards;
}

@keyframes wrapAnimateOut {
    0% {
        background: rgba(0, 0, 0, 0.35);
    }

    100% {
        background: rgba(0, 0, 0, 0);
    }
}

.frameAnimate {
    animation: frameAnimate 0.5s ease forwards;
}

@keyframes frameAnimate {
    0% {
    }

    100% {
        opacity: 1;
        top: 0vh;
    }
}

.frameAnimateOut {
    animation: frameAnimateOut 0.5s ease forwards;
}

@keyframes frameAnimateOut {
    0% {
        opacity: 1;
        top: 0vh;
    }

    100% {
        opacity: 0;
        top: 100vh;
    }
}

.content_main_top {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.bottomFrame-top {
    display: flex;
    flex-direction: row;
    justify-content: center;
}
.content_main_top_title {
    font-size: 29px;
    font-weight: bold;
    letter-spacing: 7px;
}

.submit_payMethod {
    width: 690px;
    padding: 25px;
    box-sizing: border-box;
    background-color: white;
    border-radius: 16px;
    /*border-bottom-style: solid;*/
    /*border-bottom-width: 1px;*/
    /*border-bottom-color:#f4f4f4;*/
    /*border-top-style: solid;*/
    /*border-top-width: 1px;*/
    /*border-top-color:#f4f4f4;*/
}

.submit_payMethod_Content {
    display: flex;
    justify-content: space-between;
    flex-direction: row;
    padding-left: 20px;
    padding-right: 20px;
}
.submit_payMethod_Content_Title {
    padding-top: 12px;
    padding-bottom: 12px;
    font-size: 28px;
    font-weight: 400;
    color: rgba(26, 26, 30, 1);
    display: block;
}

.submit_payMethod_Content_Title_wrap {
    padding-left: 50px;
    display: flex;
    flex-direction: column;
}
.submit_payMethod_Content_Column_wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.submit_payMethod_Content_Column_image {
    display: flex;
    flex-direction: row;
}

.mine-order-icon {
    font-family: iconfont2;

    font-size: 20px !important;
}

.bottomFrame-button {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 380px;
    height: 80px;
    margin: 20px 20px;
    border-radius: 20px;
}
.realName_botton {
    position: fixed;
    bottom: 20px;
    width: 750px;
    display: flex;
    flex-direction: row;
    justify-content: center;
}
.realName_botton_text {
    border-radius: 12px;
    font-size: 32px;
    padding: 20px 60px;
    color: white;
    background-color: #ff8400;
}
</style>

